use bool type (#992)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Fri, 20 Jan 2023 18:14:35 +0000 (11:14 -0700)
committerGitHub <noreply@github.com>
Fri, 20 Jan 2023 18:14:35 +0000 (11:14 -0700)
* use bools instead of ints.

* another bool parameter.

defs.h
kml.cc
kml.h
main.cc
util.cc
xcsv.cc
xcsv.h

diff --git a/defs.h b/defs.h
index b49d0ab4d26358b6e2acdff60b859ec8f586bff3..6ec2cbc7cea972efe7a5bb0087e62120029eaf80 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -988,7 +988,7 @@ struct ff_vecs_t {
 [[noreturn]] void fatal(const char*, ...) PRINTFLIKE(1, 2);
 void warning(const char*, ...) PRINTFLIKE(1, 2);
 
-void printposn(double c, int is_lat);
+void printposn(double c, bool is_lat);
 
 void* xcalloc(size_t nmemb, size_t size);
 void* xmalloc(size_t size);
diff --git a/kml.cc b/kml.cc
index c4c0a4fa468bd3d4e08fcf6961f673bf09a21c5f..1d9fa281d047306258bdb219538ffa0109964b42 100644 (file)
--- a/kml.cc
+++ b/kml.cc
@@ -394,7 +394,7 @@ void KmlFormat::wr_position_init(const QString& fname)
 {
   posnfilename = fname;
   posnfilenametmp = QStringLiteral("%1-").arg(fname);
-  realtime_positioning = 1;
+  realtime_positioning = true;
   max_position_points = xstrtoi(opt_max_position_points, nullptr, 10);
 }
 
@@ -437,7 +437,7 @@ void KmlFormat::kml_output_linestyle(char* /*color*/, int width) const
 
 
 void KmlFormat::kml_write_bitmap_style_(const QString& style, const QString& bitmap,
-                                        int highlighted, int force_heading) const
+                                        bool highlighted, bool force_heading) const
 {
   int is_track = style.startsWith("track");
   int is_multitrack = style.startsWith("multiTrack");
@@ -485,7 +485,7 @@ void KmlFormat::kml_write_bitmap_style_(const QString& style, const QString& bit
 void KmlFormat::kml_write_bitmap_style(kml_point_type pt_type, const QString& bitmap,
                                        const QString& customstyle) const
 {
-  int force_heading = 0;
+  bool force_heading = false;
   QString style;
   switch (pt_type) {
   case kmlpt_track:
@@ -502,15 +502,15 @@ void KmlFormat::kml_write_bitmap_style(kml_point_type pt_type, const QString& bi
     break;
   case kmlpt_other:
     style = customstyle;
-    force_heading = 1;
+    force_heading = true;
     break;
   default:
     fatal("kml_output_point: unknown point type");
     break;
   }
 
-  kml_write_bitmap_style_(style, bitmap, 0, force_heading);
-  kml_write_bitmap_style_(style, bitmap, 1, force_heading);
+  kml_write_bitmap_style_(style, bitmap, false, force_heading);
+  kml_write_bitmap_style_(style, bitmap, true, force_heading);
 
   writer->writeStartElement(QStringLiteral("StyleMap"));
   writer->writeAttribute(QStringLiteral("id"), style);
@@ -660,17 +660,17 @@ void KmlFormat::kml_output_header(const route_head* header, const computed_trkda
   }
 }
 
-int KmlFormat::kml_altitude_known(const Waypoint* waypoint)
+bool KmlFormat::kml_altitude_known(const Waypoint* waypoint)
 {
   if (waypoint->altitude == unknown_alt) {
-    return 0;
+    return false;
   }
   // We see way more data that's sourced at 'zero' than is actually
   // precisely at 0 MSL.
   if (fabs(waypoint->altitude) < 0.01) {
-    return 0;
+    return false;
   }
-  return 1;
+  return true;
 }
 
 void KmlFormat::kml_write_coordinates(const Waypoint* waypointp) const
@@ -877,12 +877,12 @@ void KmlFormat::kml_output_tailer(const route_head* header)
 
   // Add a linestring for this track?
   if (export_lines && header->rte_waypt_ct() > 0) {
-    int needs_multigeometry = 0;
+    bool needs_multigeometry = false;
 
     foreach (const Waypoint* tpt, header->waypoint_list) {
       int first_in_trk = tpt == header->waypoint_list.front();
       if (!first_in_trk && tpt->wpt_flags.new_trkseg) {
-        needs_multigeometry = 1;
+        needs_multigeometry = true;
         break;
       }
     }
@@ -1499,18 +1499,18 @@ void KmlFormat::kml_mt_simple_array(const route_head* header,
 }
 
 // True if at least two points in the track have timestamps.
-int KmlFormat::track_has_time(const route_head* header)
+bool KmlFormat::track_has_time(const route_head* header)
 {
   int points_with_time = 0;
   foreach (const Waypoint* tpt, header->waypoint_list) {
     if (tpt->GetCreationTime().isValid()) {
       points_with_time++;
       if (points_with_time >= 2) {
-        return 1;
+        return true;
       }
     }
   }
-  return 0;
+  return false;
 }
 
 // Simulate a track_disp_all callback sequence for a single track.
diff --git a/kml.h b/kml.h
index 3eec80157060b13d6f2f88b84299be79fcab1746..5c8e652747ed270cf62ea3fd9f202fec9f433cd3 100644 (file)
--- a/kml.h
+++ b/kml.h
@@ -133,14 +133,14 @@ private:
   void gx_trk_when(const QString& args, const QXmlStreamAttributes* attrs);
   void gx_trk_coord(const QString& args, const QXmlStreamAttributes* attrs);
   void kml_output_linestyle(char* color, int width) const;
-  void kml_write_bitmap_style_(const QString& style, const QString& bitmap, int highlighted, int force_heading) const;
+  void kml_write_bitmap_style_(const QString& style, const QString& bitmap, bool highlighted, bool force_heading) const;
   void kml_write_bitmap_style(kml_point_type pt_type, const QString& bitmap, const QString& customstyle) const;
   void kml_output_timestamp(const Waypoint* waypointp) const;
   static void kml_td(gpsbabel::XmlStreamWriter& hwriter, const QString& boldData, const QString& data);
   static void kml_td(gpsbabel::XmlStreamWriter& hwriter, const QString& data);
   void kml_output_trkdescription(const route_head* header, const computed_trkdata* td) const;
   void kml_output_header(const route_head* header, const computed_trkdata* td) const;
-  static int kml_altitude_known(const Waypoint* waypoint);
+  static bool kml_altitude_known(const Waypoint* waypoint);
   void kml_write_coordinates(const Waypoint* waypointp) const;
   void kml_output_lookat(const Waypoint* waypointp) const;
   void kml_output_positioning(bool tessellate) const;
@@ -166,7 +166,7 @@ private:
   void kml_track_disp(const Waypoint* waypointp) const;
   void kml_track_tlr(const route_head* header);
   void kml_mt_simple_array(const route_head* header, const char* name, wp_field member) const;
-  static int track_has_time(const route_head* header);
+  static bool track_has_time(const route_head* header);
   void write_as_linestring(const route_head* header);
   void kml_mt_hdr(const route_head* header);
   void kml_mt_tlr(const route_head* header) const;
@@ -196,15 +196,15 @@ private:
   char* opt_rotate_colors{nullptr};
   char* opt_precision{nullptr};
 
-  int export_lines{};
-  int export_points{};
-  int export_track{};
-  int floating{};
-  int extrude{};
-  int trackdata{};
-  int trackdirection{};
+  bool export_lines{};
+  bool export_points{};
+  bool export_track{};
+  bool floating{};
+  bool extrude{};
+  bool trackdata{};
+  bool trackdirection{};
   int max_position_points{};
-  int rotate_colors{};
+  bool rotate_colors{};
   int line_width{};
   int precision{};
 
@@ -221,7 +221,7 @@ private:
   gpsbabel::File* oqfile{nullptr};
   gpsbabel::XmlStreamWriter* writer{nullptr};
 
-  int realtime_positioning{};
+  bool realtime_positioning{};
   bounds kml_bounds{};
   gpsbabel::DateTime kml_time_max;
   gpsbabel::DateTime kml_time_min;
diff --git a/main.cc b/main.cc
index 299406f825b659a7753a6392ab17584fe8f40e43..d70c4ec4f7d22d786efc0cd9ea888e801426574d 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -224,8 +224,8 @@ public:
     if (wpt->GetCreationTime().isValid()) {
       printf("%s ", qPrintable(wpt->creation_time.toString()));
     }
-    printposn(wpt->latitude,1);
-    printposn(wpt->longitude,0);
+    printposn(wpt->latitude, true);
+    printposn(wpt->longitude, false);
     if (!wpt->description.isEmpty()) {
       printf("%s/%s",
              global_opts.synthesize_shortnames ?
diff --git a/util.cc b/util.cc
index e7d0e67672e2a45c78c65b2e6a344aade41b35aa..4819cdf110459de6e2ad2bc72bf96ec2e454eb37 100644 (file)
--- a/util.cc
+++ b/util.cc
@@ -480,7 +480,7 @@ str_match(const char* str, const char* match)
 }
 
 void
-printposn(const double c, int is_lat)
+printposn(const double c, bool is_lat)
 {
   char d;
   if (is_lat) {
diff --git a/xcsv.cc b/xcsv.cc
index e55f4b5e4d03e14087a6c3f3380877b4d2a26006..717f55c83cdc1ff2a669adf7b05afeea5cc88849 100644 (file)
--- a/xcsv.cc
+++ b/xcsv.cc
@@ -261,7 +261,7 @@ XcsvFormat::yyyymmdd_to_time(const QString& s)
  * sscanftime - Parse a date buffer using strftime format
  */
 time_t
-XcsvFormat::sscanftime(const char* s, const char* format, const int gmt)
+XcsvFormat::sscanftime(const char* s, const char* format, bool gmt)
 {
   struct tm stm;
   memset(&stm, 0, sizeof(stm));
@@ -336,7 +336,7 @@ XcsvFormat::writetime(const char* format, const gpsbabel::DateTime& t, bool gmt)
 }
 
 QString
-XcsvFormat::writehms(const char* format, time_t t, int gmt)
+XcsvFormat::writehms(const char* format, time_t t, bool gmt)
 {
   static struct tm no_time = tm();
   static struct tm* stmp = &no_time;
@@ -357,7 +357,7 @@ XcsvFormat::writehms(const char* format, time_t t, int gmt)
 }
 
 QString
-XcsvFormat::writehms(const char* format, const gpsbabel::DateTime& t, int gmt)
+XcsvFormat::writehms(const char* format, const gpsbabel::DateTime& t, bool gmt)
 {
   return writehms(format, t.toTime_t(), gmt);
 }
@@ -621,14 +621,14 @@ XcsvFormat::xcsv_parse_val(const QString& value, Waypoint* wpt, const XcsvStyle:
     wpt->SetCreationTime(yyyymmdd_to_time(value));
     break;
   case XcsvStyle::XT_GMT_TIME:
-    wpt->SetCreationTime(sscanftime(s, fmp.printfc.constData(), 1));
+    wpt->SetCreationTime(sscanftime(s, fmp.printfc.constData(), true));
     break;
   case XcsvStyle::XT_LOCAL_TIME:
     if (!gpsbabel_testmode()) {
-      wpt->creation_time = wpt->creation_time.addSecs(sscanftime(s, fmp.printfc.constData(), 0));
+      wpt->creation_time = wpt->creation_time.addSecs(sscanftime(s, fmp.printfc.constData(), false));
     } else {
       /* Force constant time zone for test */
-      wpt->creation_time = wpt->creation_time.addSecs(sscanftime(s, fmp.printfc.constData(), 1));
+      wpt->creation_time = wpt->creation_time.addSecs(sscanftime(s, fmp.printfc.constData(), true));
     }
     break;
   /* Useful when time and date are in separate fields
@@ -1382,10 +1382,10 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt)
       buff = writetime(fmp.printfc.constData(), wpt->GetCreationTime(), false);
       break;
     case XcsvStyle::XT_HMSG_TIME:
-      buff = writehms(fmp.printfc.constData(), wpt->GetCreationTime(), 1);
+      buff = writehms(fmp.printfc.constData(), wpt->GetCreationTime(), true);
       break;
     case XcsvStyle::XT_HMSL_TIME:
-      buff = writehms(fmp.printfc.constData(), wpt->GetCreationTime(), 0);
+      buff = writehms(fmp.printfc.constData(), wpt->GetCreationTime(), false);
       break;
     case XcsvStyle::XT_ISO_TIME:
       buff = writetime("%Y-%m-%dT%H:%M:%SZ", wpt->GetCreationTime(), true);
diff --git a/xcsv.h b/xcsv.h
index c3f55eaf6f2d09ec0161041cdbce5c5e6a49eab0..afa2711e4477b395919734bcb9a9e5c6ebad1929 100644 (file)
--- a/xcsv.h
+++ b/xcsv.h
@@ -357,12 +357,12 @@ private:
   /* Member Functions */
 
   static QDateTime yyyymmdd_to_time(const QString& s);
-  static time_t sscanftime(const char* s, const char* format, int gmt);
+  static time_t sscanftime(const char* s, const char* format, bool gmt);
   static time_t addhms(const char* s, const char* format);
   static QString writetime(const char* format, time_t t, bool gmt);
   static QString writetime(const char* format, const gpsbabel::DateTime& t, bool gmt);
-  static QString writehms(const char* format, time_t t, int gmt);
-  static QString writehms(const char* format, const gpsbabel::DateTime& t, int gmt);
+  static QString writehms(const char* format, time_t t, bool gmt);
+  static QString writehms(const char* format, const gpsbabel::DateTime& t, bool gmt);
   static long int time_to_yyyymmdd(const QDateTime& t);
   static garmin_fs_t* gmsd_init(Waypoint* wpt);
   static void xcsv_parse_val(const QString& value, Waypoint* wpt, const XcsvStyle::field_map& fmp, xcsv_parse_data* parse_data, int line_no);